﻿using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Wechat.Core.Models
{
    /// <summary>
    /// 微信api 调用的基础令牌
    /// { 
    ///     "access_token":"ACCESS_TOKEN",
    ///     "expires_in":7200,
    /// }
    /// </summary>
    [JsonObject]
    public class AccessTokenResponse : StandardResponse
    {
        /// <summary>
        /// 
        /// </summary>
        [JsonProperty(ApiGlobalKey.ACCESS_TOKEN)]
        public string Token { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [JsonProperty("expires_in")]
        public int ExpiresIn { get; set; }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return Token;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="accessToken"></param>
        public static implicit operator String(AccessTokenResponse accessToken)
        {
            if (accessToken == null)
                return null;
            return accessToken.ToString();
        }
    }
}
